/******************************************************************************
 * * sms_Screened.c - implementation of sms Screened functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "sms_include.h"

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Screened_Msgs(lv_obj_t *pBtn,lv_event_t event)
{
    // Sent Screened Msgs function
    // read Screened Msgs messages
    // create Messages_Opening chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pOpening = NULL;
    CB_FUNC          callback  = Sms_Scrn_Timeout;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));
    g_MsgGlobalCtrl.CurOpenBox     = SCREENED_MESSAGES;
    pOpening->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING, &FuncList, (void *)pOpening);

    if (NULL != g_MsgGlobalCtrl.pScrnMsgContentInfo)
    {    // scrn has been read
        // 2s timer start
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_OPENING);
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }
} /* Sms_Screened_Msgs */

/**
 * sub-module entry
 * param (in)
 * return  VOID
 */
VOID Sms_Scrn_Timeout(VOID* id)
{
    // create Messages_Screened_Msgs chart
    UINT32* Id = (UINT32 *)id;
    Sms_Screened_Msgs_List(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Screened_Msgs_List(UINT32 id)
{
    // Sent Screened Msgs list function
    // create Messages_Screened_Msgs.
    UINT32                     i   = 0;
    UINT32                     Cnt = 0;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pScrn      = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;
    Msg_Content_Info_t         *pTemp      = NULL;

    pScrn = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pScrn, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pScrnMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pScrnMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    g_MsgGlobalCtrl.pChart = pScrn;

    pScrn->TitleBar.TxtId      = PHONE_TEXT_ID_SCREENED_SMS;
    pScrn->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pScrn->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pScrn->List.ListButtonCnt = Cnt;
    pScrn->List.Index         = 0;
    pScrn->List.ButtonList    = ButtonList;

    for (i = 0; i < Cnt; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pScrnMsgContentInfo, pTemp);
        }
        else
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pScrnMsgContentInfo);
        }
        ButtonList[i].ButtonIndex = i;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pTemp->pContact;
        if (MMI_MODEM_UNREAD == pTemp->SmsType)
        {
            ButtonList[i].SymbolId1 = SYMBOL_UNREAD_SMS;
        }
        else
        {
            ButtonList[i].SymbolId1 = SYMBOL_READ_SMS;
        }
        if (MMI_MODEM_SIM_1 == pTemp->SimId)
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM1;
        }
        else
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM2;
        }
        ButtonList[i].ReleaseFun = Sms_Screened_Msgs_List_Read;
        ButtonList[i].Valid      = true;
    }
    pScrn->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pScrn->BtnBar.ButtonR.Valid = true;

    pScrn->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_READ;
    pScrn->BtnBar.ButtonM.Valid = true;

    pScrn->KeyFunc = Sms_Screened_Msgs_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Screened_Msgs_On_Create;
    FuncList.OnDestroy      = Sms_Screened_Msgs_Destory;   // temp
    FuncList.OnSaveState    = Sms_Common_Save;             // temp
    FuncList.OnRestoreState = Sms_Screened_Msgs_On_Create; // temp

    Nav_Forward(id, ACT_ID_MESSAGES_SCREENED_MSGS, &FuncList, (void *)pScrn);
} /* Sms_Screened_Msgs_List */

/**
 * Common Process UI create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Screened_Msgs_On_Create(VOID *pDesc)
{
    UINT8                      i      = 0;
    UI_Normal_List_Only_Desc_t *pScrn = pDesc;

    g_MsgGlobalCtrl.pChart = pDesc;
    Msg_Content_Info_t *pTemp = NULL;
    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pScrnMsgContentInfo);
    while (NULL != pTemp)
    {
        pScrn->List.ButtonList[i++].Button->user_data.user_data = pTemp;
        pTemp                                        = _lv_ll_get_next(g_MsgGlobalCtrl.pScrnMsgContentInfo, pTemp);
    }
}

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Screened_Msgs_Destory(VOID *pDesc)
{
    UI_Normal_List_Only_Desc_t *pInput = pDesc;

    Hal_Mem_Free(pInput->List.ButtonList);
    pInput->List.ButtonList = NULL;
    Sms_Common_All_Global_Destory(pDesc);
}

/**
 * entry of mesInbox
 * param (in) lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Screened_Msgs_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES, NULL, NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);    // temp
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Scrn_Empty(VOID)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pEmpty  = NULL;
    CB_FUNC          callback = Sms_Scrn_Empty_Timeout;

    pEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pEmpty, 0, sizeof(UI_Status_Desc_t));

    pEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_SCR_FOLDER_EMPTY;
    pEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX_EMPTY, &FuncList, (void *)pEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_INBOX_EMPTY);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Scrn_Empty_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Screened_Msgs_List_Read(lv_obj_t *pBtn,lv_event_t event)
{
    // Sent Screened Msgs list function
    // create Messages_Opening chart
    MMI_Modem_Read_Sms_Detail_On_Sim_Req_t *pReadSmsReq;
    Nav_Func_List_t                        FuncList;
    UI_Status_Desc_t                       *pOpening = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));

    pOpening->ContLabel.LabelAlign = LV_ALIGN_CENTER;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_CENTER;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    g_MsgGlobalCtrl.pCurrentViewMsg = pBtn->user_data.user_data;

    pReadSmsReq = (MMI_Modem_Read_Sms_Detail_On_Sim_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Read_Sms_Detail_On_Sim_Req_t));

    Hal_Mem_Set(pReadSmsReq, 0, sizeof(MMI_Modem_Read_Sms_Detail_On_Sim_Req_t));

    pReadSmsReq->MsgIndex = g_MsgGlobalCtrl.pCurrentViewMsg->MsgIndex;

    pReadSmsReq->SimId = g_MsgGlobalCtrl.pCurrentViewMsg->SimId;

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING2, &FuncList, (void *)pOpening);

    MMI_Modem_Read_Sms_Detail_On_Sim_Req(pReadSmsReq);
} /* Sms_Screened_Msgs_List_Read */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Screened_Msgs_Body(lv_obj_t *pBtn)
{
    // sms Screened Msgs body function
    // create Messages_Screened_Msgs_Body chart
    Nav_Func_List_t             FuncList;
    UI_Normal_NoTitle_Ta_Desc_t *pReadMsg = NULL;

    pReadMsg = (UI_Normal_NoTitle_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Ta_Desc_t));
    Hal_Mem_Set(pReadMsg, 0, sizeof(UI_Normal_NoTitle_Ta_Desc_t));

    pReadMsg->ContLabelTl.TxtId    = PHONE_TEXT_ID_MEM_STA;
    pReadMsg->ContLabelTl.TxtAlign = LV_LABEL_ALIGN_CENTER;

    pReadMsg->ContLabelTr.TxtId    = LV_LANG_TXT_ID_NONE;
    pReadMsg->ContLabelTr.TxtAlign = LV_LABEL_ALIGN_CENTER;
    pReadMsg->ContTa.TaTxt         = NULL;

    pReadMsg->ButtonBar.ButtonL.TxtId      = PHONE_TEXT_ID_OPT;
    pReadMsg->ButtonBar.ButtonL.ReleaseFun = NULL;
    pReadMsg->ButtonBar.ButtonL.Valid      = true;

    pReadMsg->ButtonBar.ButtonR.TxtId      = PHONE_TEXT_ID_BACK;
    pReadMsg->ButtonBar.ButtonR.ReleaseFun = NULL;
    pReadMsg->ButtonBar.ButtonR.Valid      = true;

    pReadMsg->KeyFunc = Sms_Screened_Msgs_Body_Handle;                       // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Ta_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Screened_Msgs_Body_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory;               // temp
    FuncList.OnSaveState    = Sms_Common_Save;                  // temp
    FuncList.OnRestoreState = Sms_Screened_Msgs_Body_On_Create; // temp

    if (MMI_MODEM_UNREAD == g_MsgGlobalCtrl.pCurrentViewMsg->SmsType)
    {
        g_MsgGlobalCtrl.pCurrentViewMsg->SmsType = MMI_MODEM_READ;
    }

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX_MSGBODY, &FuncList, (void *)pReadMsg);

    return(LV_RES_OK);
} /* Sms_Screened_Msgs_Body */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Screened_Msgs_Body_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SCREENED_MSGS, NULL, NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
        if (KEY_SOFTLEFT == key_val)
        {
            Sms_Screened_Msgs_Opt(obj);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Screened_Msgs_Body_On_Create(VOID *pDesc)
{
    UI_Normal_NoTitle_Ta_Desc_t *pReadMsg = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pReadMsg               = g_MsgGlobalCtrl.pChart;

    lv_label_set_text(pReadMsg->ContLabelTl.Label, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
    lv_obj_set_style_local_text_font(pReadMsg->ContTa.TextArea,
                                     LV_TEXTAREA_PART_BG,
                                     LV_STATE_DEFAULT,
                                     LV_FONT_PTR_DRIODSANSFALLBACKFULL_SMALL);
    lv_textarea_set_text(pReadMsg->ContTa.TextArea, g_MsgGlobalCtrl.pReadSmsText);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Screened_Msgs_Opt(lv_obj_t *pBtn)
{
    // sms Screened Msgs options function
    // create Messages_Screened_Opt. chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pScrnOpt   = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    pScrnOpt = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pScrnOpt, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);

    g_MsgGlobalCtrl.pChart = pScrnOpt;

    pScrnOpt->TitleBar.TxtId      = LV_LANG_TXT_ID_NONE;
    pScrnOpt->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pScrnOpt->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pScrnOpt->List.ListButtonCnt  = 2;
    pScrnOpt->List.Index          = 0;
    pScrnOpt->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_DELETE;
    ButtonList[0].ReleaseFun  = Sms_Screened_Msgs_Opt_Delete;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_DEL_FROM_SCRLIST;
    ButtonList[1].ReleaseFun  = Sms_Screened_Msgs_Opt_Delete_From_List;
    ButtonList[1].Valid       = true;

    pScrnOpt->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pScrnOpt->BtnBar.ButtonR.Valid = true;

    pScrnOpt->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pScrnOpt->BtnBar.ButtonM.Valid = true;

    pScrnOpt->KeyFunc = Sms_Screened_Msgs_Opt_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SCREENED_OPT, &FuncList, (void *)pScrnOpt);
    lv_label_set_text(pScrnOpt->TitleBar.Label, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);

    return(LV_RES_OK);
} /* Sms_Screened_Msgs_Opt */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Screened_Msgs_Opt_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }
    return(Result);    // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Screened_Msgs_Opt_Delete(lv_obj_t *pBtn,lv_event_t event)
{
    // sms Screened Msgs options delete function
    // create Messages_Deleted_Confirm. chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDelete = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelete = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDelete, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDelete;

    pDelete->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDelete->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_SMS_Q;
    pDelete->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDelete->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDelete->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelete->ButtonBar.ButtonR.Valid = true;

    pDelete->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    pDelete->ButtonBar.ButtonM.Valid = true;

    pDelete->KeyFunc = Sms_Screened_Msgs_Opt_Delete_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_CONFIRM, &FuncList, (void *)pDelete);
} /* Sms_Screened_Msgs_Opt_Delete */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Screened_Msgs_Opt_Delete_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Screened_Msgs_Opt_Delete_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Screened_Msgs_Opt_Delete_OK(lv_obj_t *pBtn)
{
    // sms Screened Msgs options delete OK function
    // delete the message
    // create Messages_Deleted_Status chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);
    Sms_Common_Delete_Single_Sms(&g_MsgGlobalCtrl.pScrnMsgContentInfo);

    Sms_Screened_Msgs_Opt_Delete_Done(NULL);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pLabel
 * return  lv_res_t
 */
lv_res_t Sms_Screened_Msgs_Opt_Delete_Done(lv_obj_t *pLabel)
{
    // sms Screened Msgs options delete done function
    // create Messages_Deleted_Done chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteDone = NULL;
    CB_FUNC          callback     = Sms_Screened_Msgs_Opt_Delete_Done_Timeout;

    pDeleteDone = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteDone, 0, sizeof(UI_Status_Desc_t));

    pDeleteDone->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteDone->ContLabel.TxtId      = PHONE_TEXT_ID_DELETED;
    pDeleteDone->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteDone->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteDone->ContImg.Img = SYMBOL_CHECKED;

    pDeleteDone->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pDeleteDone->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_DONE, &FuncList, (void *)pDeleteDone);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_DONE);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Screened_Msgs_Opt_Delete_Done_Timeout(VOID* id)
{
    // sms scrn options delete done function
    // create Messages_Deleted_Done chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES, NULL, NULL);
    Sms_Screened_Msgs(NULL,LV_EVENT_CLICKED);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Screened_Msgs_Opt_Delete_From_List(lv_obj_t *pBtn,lv_event_t event)
{
    // sms Screened Msgs options delete from list function
    // send delete number to contacts
    // delete back to Messages_Screened_Msgbody chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteList = NULL;
    INT8                     *pTemp       = NULL;
    INT8                     str[100];

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteList = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteList, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteList;

    pDeleteList->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteList->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_NUM_FROM_LIST_Q;
    pDeleteList->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteList->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteList->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteList->ButtonBar.ButtonR.Valid = true;

    pDeleteList->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteList->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteList->ButtonBar.ButtonM.Valid      = true;

    pDeleteList->KeyFunc = Sms_Screened_Msgs_Opt_Delete_From_List_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_LIST_CONFIRM, &FuncList, (void *)pDeleteList);

    pTemp = lv_label_get_text(pDeleteList->ContenCont.ContLabel.Label);
    Hal_Mem_Set(str, 0, 100);
    strcat(str, pTemp);
    strcat(str, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
    lv_label_set_text(pDeleteList->ContenCont.ContLabel.Label, str);
} /* Sms_Screened_Msgs_Opt_Delete_From_List */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Screened_Msgs_Opt_Delete_From_List_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Screened_Msgs_Opt_Delete_From_List_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Screened_Msgs_Opt_Delete_From_List_OK(lv_obj_t *pBtn)
{
    Sms_Screened_Msgs_Opt_Delete_From_List_Timeout(MSG_INVAILD_TIMER_ID);
    Contacts_Del_Num_From_Scrn_List_Req(ACT_ID_MESSAGES_DELETED_LIST_STATUS, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Screened_Msgs_Opt_Delete_From_List_Timeout(UINT32 id)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteDone = NULL;
    CB_FUNC          callback     = Sms_Screened_Msgs_Opt_Delete_List_Sts_Timeout;

    pDeleteDone = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteDone, 0, sizeof(UI_Status_Desc_t));

    pDeleteDone->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteDone->ContLabel.TxtId      = PHONE_TEXT_ID_NUM_HAS_BEEN_DEL;
    pDeleteDone->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteDone->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteDone->ContImg.Img = SYMBOL_CHECKED;

    pDeleteDone->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pDeleteDone->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_LIST_STATUS, &FuncList, (void *)pDeleteDone);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_LIST_STATUS);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Screened_Msgs_Opt_Delete_List_Sts_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_INBOX_MSGBODY, NULL, NULL);
}
